package com.wiznbiz.okagent;




import android.app.Activity;
import android.os.Bundle;

/**
 * 어플리케이션 Activity에서 상속 해야 하는 기본 Activity 클래스<br>
 * android.app.Activity 클래스 대용으로 사용
 *  
 * @author Administrator
 *
 */
public class BaseActivity extends Activity {
	@SuppressWarnings("unused")
	private final String TAG = "<<<BaseActivity>>>";
	

	/**
	 * Application 객체
	 */
	public OkAgentApplication agentApp;
	
	/**
	 * ProgressDialog 객체
	 */
	public CustomProgressDialog progressDlg;	
	
	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		agentApp = (OkAgentApplication) this.getApplication();
		progressDlg = new CustomProgressDialog(this);
	}
	
	@Override
	public void onDestroy(){
		super.onDestroy();
		try{
			if(progressDlg != null){
				progressDlg.cancel();
				progressDlg = null;
			}
			if(agentApp != null){
				agentApp = null;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}	
	
	@Override
	public void onBackPressed(){
		super.onBackPressed();
	}
	
	public void showProgress(boolean isCancelable){
		try{
			progressDlg.setCancelable(isCancelable);
			progressDlg.show();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void showProgress(){
		showProgress(false);
	}	
	
	public void closeProgress() {
		try{
	    	if (progressDlg.isShowing())
	    		progressDlg.dismiss();
		}catch(Exception e){};
	}
	
	public void setProgressMsg(String msg){
		progressDlg.setMessage(msg);
	}
	
	public void setProgressMsg(int resId){
		progressDlg.setMessage(resId);
	}	
}
